﻿namespace CSharpTest
{
    public class SqliteDbContext : DbContext
    {
        public SqliteDbContext(DbContextOptions<SqliteDbContext> options) : base(options)
        {
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            var mappingTypeBuilder = modelBuilder.Entity<Mapping>().ToTable("Mappings");
            mappingTypeBuilder.Ignore(m=>m.Action);
        }
        public DbSet<Model> Models { get; set; }
        public DbSet<ModelProfile> ModelProfiles { get; set; }
        public DbSet<Mapping> Mappings { get; set; }
    }
    public static class SqliteDbContextCreator
    {
        public static SqliteDbContext Create(string connectionString)
        {
            var optionsBuilder = new DbContextOptionsBuilder<SqliteDbContext>();
            optionsBuilder.UseSqlite(connectionString);
            return new SqliteDbContext(optionsBuilder.Options);
        }
    }
    public class Model
    {
        public Guid Id { get; set; }
        public string Type { get; set; }
    }
    public class ModelProfile
    {
        public Guid Id { get; set; }
        public Guid ModelId { get; set; }
        public string Key { get; set; }
        public string Value { get; set; }
    }
    public class Mapping 
    {
        public Guid Id { get; set; }
        public Guid TriggerId { get; set; }
        public Guid ActionId { get; set; }
        public Action Action { get; set; }
        public bool Enabled { get; set; }
    }


}
